/*
 * Copyright 2007-2008 Andrew O'Malley
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


package ws.quokka.core.bootstrap_util;

import java.util.Set;


/**
 * ProfilesMatcher determines if the active profiles match a given expression.
 * Note: this class delegates to a parser generated by JavaCC. It's only purpose
 * is to provide an interface that won't confuse IDEs. If this class won't compile, make
 * sure you've run "compile" from quokka at least once to generate the parser
 */
public class ProfilesMatcher {
    //~ Methods --------------------------------------------------------------------------------------------------------

    /**
     * Returns true if the profiles given are enabled given the currently active profiles
     */
    public boolean matches(String expression, Set activeProfiles) {
        // TODO: Invoke via reflection to shut the IDE up
//        Reflect reflect = new Reflect();
//        Class clazz = reflect.loadClass(getClass().getClassLoader(), "ws.quokka.core.bootstrap_util.profile.ProfilesMatcher");
//        reflect.construct(clazz)
//        reflect.invoke(clazz, "matches", new Class[] {Set.class, String.class});
        return new ws.quokka.core.bootstrap_util.profile.ProfilesMatcher(activeProfiles, expression).matches();
    }
}
